Ext.define('CDR.view.manager.pbx.PBXViewContainer', {
	extend: 'Ext.panel.Panel',
	alias : 'widget.pbxviewcontainer',
	pbxFactory: null,
	layout: 'border',
	border: false,
	currentPbx: null,
	initComponent: function() {
		var me = this;
		me.callParent();
		me.formContainer = Ext.create('widget.container', {
			region:'south',
			height:'50%',
			layout:'fit',
			split: true
		});
		me.add(me.formContainer);
		me.add({xtype: 'panel', region:'center', layout:'fit',items:[Ext.createWidget('pbxview',{region:'center', id: 'x-view-pbxviewcontainer-pbxview'})]});
		Ext.createWidget('pbxviewform', {region: 'center', id:'x-view-pbxviewcontainer-pbxviewform'});
		me.profile = Ext.createWidget('profile', {id: 'x-view-pbxviewcontainer-pbxprofileview'});
	},
	dockedItems: [{
		xtype: 'toolbar',
		items: [{
			text: 'New PBX',
			iconCls: 'icon-add',
			action: 'new-pbx'
		}, '-', '', {
			fieldLabel: 'Search',
			labelWidth: 45,
			xtype: 'textfield',
			action: 'filter'
		}]
	}],
	
	replaceSouthView: function(view){
		this.formContainer.removeAll(false);
		this.formContainer.add(view);
	},
	
	addProfile: function(seletedNode){
		this.formContainer.removeAll(false);
		this.profile.reloadData(seletedNode);
		this.formContainer.add(this.profile);
	}
});
